package org.bhujmandir.android;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class MusicActivity extends Activity{
	Context context;
	ListView itemsListView;
	TextView title;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		context = this;
		setContentView(R.layout.main);
		
		title = (TextView)findViewById(R.id.title);
		title.setText("Music");
		//title.setVisibility(8);  //Set visibility to gone

		
		String[] items = getResources().getStringArray(R.array.musicHeadings);
		itemsListView = (ListView)findViewById(R.id.listView);
		itemsListView.setAdapter(new ArrayAdapter<String>(context,R.layout.std_list_item,items));

		itemsListView.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				String item = (((TextView) view).getText()).toString();
		    	 if(item.equals("All Music"))	{
		    		 Bundle extraVars = new Bundle();
		    		 extraVars.putString("type","Kirtans");
		    		 extraVars.putString("title","All Music");
		    		 extraVars.putBoolean("sort",true);
		    		 
		    		 Intent intent = new Intent(context,MediaActivity.class);
		    		 intent.putExtras(extraVars);
		    		 startActivity(intent); 
		    	 }else{
		    		 // TODO Add other activities to launch for on click
		    	 }
		     }
		   });
		   
	}
	

}

/*
public class MusicActivity extends ListActivity{
	Context context;
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    context = this;
	    //setContentView(R.layout.main);
	   String[] headings = getResources().getStringArray(R.array.musicHeadings);
	   setListAdapter(new ArrayAdapter<String>(context,R.layout.std_list_item,headings));
	   ListView headingsView = getListView();
	   headingsView.setTextFilterEnabled(true);
	   
	   headingsView.setOnItemClickListener(new OnItemClickListener() {
	     public void onItemClick(AdapterView<?> parent, View view,
	         int position, long id) {
		    	 String item = (((TextView) view).getText()).toString();
		    	 if(item.equals("All Music"))	{
		    		 Bundle extraVars = new Bundle();
		    		 extraVars.putString("type","Kirtans");
		    		 Intent intent = new Intent(context,MediaActivity.class);
		    		 intent.putExtras(extraVars);
		    		 startActivity(intent); 
		    	 }else{
		    		 // TODO Add other activities to launch for on click
		    	 }
	     	}
	   });

	}

}
*/
